package com.lagou.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.dao.IArticleDao;
import com.lagou.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lbq
 * @version 1.0
 * @date 2021/1/12 21:19
 */
@Service
public class ArticleService {

    @Autowired
    private IArticleDao iArticleDao;

    public PageInfo<Article> selectByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        // 调用dao的查询方法
        List<Article> articles = iArticleDao.selectList();
        // 封装分页结果，并返回
        return new PageInfo<Article>(articles);
    }
}
